function deepCopy(obj) {
    const newTemp = obj instanceof Array ? [] : {}
    for (const key in obj) {
        if(!obj.hasOwnProperty(key)) continue
        console.log(key);
        if(typeof obj[key] === 'object'){
            newTemp[key] = deepCopy(obj[key])
        } else {
            newTemp[key] = obj[key]
        }
    }
    return newTemp
}

const orgAObj = {a:1,b:[2,3,4,{c:5}]}
const newObj = deepCopy(orgAObj)
newObj.a = 5
console.log(orgAObj);
console.log(newObj);
